package main

import (
	"fmt"
	"time"
)

func longWait() {
	fmt.Println("Beginning longWait()")
	time.Sleep(time.Second * 5)
	fmt.Println("Ending longWait()")
}

func shortWait() {
	fmt.Println("Beginning shortWait()")
	time.Sleep(time.Second * 2)
	fmt.Println("Ending shortWait()")
}

// channel
func sendData(ch chan string) {
	ch <- "hello"
	ch <- "world"
}

func getData(ch chan string) {
	var input string
	for {
		input = <-ch
		fmt.Println(input)
	}
}

func main() {
	fmt.Println("IN main()")
	go longWait()
	go shortWait()
	fmt.Println("sleep main")
	time.Sleep(time.Second * 6)
	fmt.Println("Ending main()")
	//channel
	ch := make(chan string)
	go sendData(ch)
	go getData(ch)
	time.Sleep(time.Second * 10)
}
